
import java.awt.Point;
import java.util.Random;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.glu.GLU;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Kyle Hill
 */
public class ScribbleBrush extends Brush {

    int size;
    Random rand = new Random();
    int count = 0;

    public void brushBegin(Point source, Point target, GLAutoDrawable drawable) {
        // initiates brush movement by setting the point size from Painter slider
        size = Painter.size;

        final GL gl = drawable.getGL();
        final GLU glu = new GLU();

        gl.glLineWidth((float) 1.0f);
        gl.glDisable(GL.GL_LINE_STIPPLE);
        brushMove(source, target, drawable);
    }

    public void brushMove(Point source, Point target, GLAutoDrawable drawable) {
        // continues brush movement by copying the color from the original picture
        // to the current mouse position
        final GL gl = drawable.getGL();
        final GLU glu = new GLU();
//               rand = new Random();
        if (Painter.imageRGBA == null) {
            System.out.println("PointBrush picture is NULL");
        } else {            
            gl.glBegin(GL.GL_LINE_LOOP);
            setColor(source, drawable);
            gl.glVertex2d(target.getX(), target.getY());
            while(count++ < Painter.fill){

                //choose random coord's for lines to be drawn
                double randomSelectionX[] = {target.getX() + rand.nextDouble()*size,
                                             target.getX() - rand.nextDouble()*size,
                };
                double randomSelectionY[] = {target.getY() + rand.nextDouble()*size,
                                             target.getY() - rand.nextDouble()*size,
                };
                gl.glVertex2d(randomSelectionX[rand.nextInt(2)], randomSelectionY[rand.nextInt(2)]);
            }
            gl.glEnd();
        }
        count = 0;
    }

    public void brushEnd(Point source, Point target) {
        // ends the brush movement
        int size = Painter.size;
    }
}
